<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: wuxin
  Date: 2023/12/29
  Time: 15:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>二级联动</title>
    　<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function (){

              $("#college").change(function (){
                  var teacherSel=$("#teacher");
                  teacherSel.find("option:not(:first)").remove();

                 var collegeId= this.value;

                 if(collegeId){
                      $.getJSON("${pageContext.request.contextPath}/example/ajaxTeacherList.action?collegeId="+collegeId,
                      function (data){
                          $(data).each(function (){
                             teacherSel.append(new Option(this.tname,this.tid));
                          });
                      });
                 }


              });


        });
    </script>


</head>
<body>

<select id="college">
    <option>请选择</option>
    <c:forEach items="${collegeList}" var="cl">
        <option value="${cl.cid}">${cl.cname}</option>
    </c:forEach>
</select>

<select id="teacher">
    <option>请选择</option>


</select>




</body>
</html>
